package jsr292.java.lang.invoke;

import jsr292.weaver.Debug;
import jsr292.weaver.opt.OptimizerContext;
import jsr292.weaver.opt.OptimizerSnippets;
import jsr292.weaver.opt.OptimizerVarAllocator;

class MHIdentity extends MethodHandle {
    public MHIdentity(MethodType methodType) {
	super(methodType);
    }

    @Override
    public Object $invoke$(Object o) throws Throwable {
	return o;
    }

    @Override
    public boolean isWeavable(Class<?> classBeingRedefined) {
        return true;
    }
    @Override
    public void weave(OptimizerContext context, OptimizerVarAllocator allocator) {
        if (Debug.DEBUG) {
            Debug.checkAllocator(allocator, this);
        }
        
	OptimizerSnippets.identity(context, allocator);
    }
}
